home *** CD-ROM | disk | FTP | other *** search
- /**************
- *
- * Enough.c - Tests for the presence of a specified amount of free total ram and
- * free chip ram.
- *
- * Synopsis - enough TOTAL [CHIP]
- *
- * Returns - 0 if enough total ram and chip ram is available.
- * 10 (AmigaDOS ERROR level) if enough total ram or chip ram is not
- * available.
- *
- * Author - Eric Kennedy ejkst@cisunx.edu
- *
- * Status - public domain
- *
- **************/
-
- #include <exec/memory.h>
-
- main(argc,argv)
- char *argv[];
- {
- long freechip, freefast;
- extern long AvailMem();
- long reqchip = 0L;
- long reqtot;
- extern long atol();
-
- if(argc>1) /* Is there a first argument? */
- {
- reqtot = atol(argv[1]);
- if(argc > 2) /* Is there a second argument? */
- reqchip = atol(argv[2]);
- }
- else
- exit(20); /* no error message--keep it small */
-
- Forbid(); /* get available memory */
- freechip = AvailMem (MEMF_CHIP);
- freefast = AvailMem (MEMF_FAST);
- Permit();
- /* compare to requested mem */
- if((freechip >= reqchip) && (freechip+freefast >= reqtot))
- exit(0); /* there was enough */
- else
- exit(10); /* there wasn't enough */
- }
-